<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('工地详情')"/>
    <link th:href="@{/css/mui.min.css}" rel="stylesheet"/>
    <link th:href="@{/css/imageview.css}" rel="stylesheet"/>
    <link th:href="@{/css/mui.imageviewer.css}" rel="stylesheet"/>
    <style>
        .title {
            font-size: 20px;
            font-family: Hack;
            color: #000;
            font-weight: bold;
        }

        .title_top {
            margin-top: 10px;
            line-height: 45px;
        }

        .line {
            width: 100;
            margin-top: 40px;
        }

        .status1 {
            float: right;
            position: absolute;
            right: 50px;
            top: 20px;
            color: green;
        }

        .status0 {
            float: right;
            position: absolute;
            right: 50px;
            top: 15px;
            color: #828080;
            font-size: 11px;
        }
    </style>
</head>
<body class="white-bg">
<div class="wrapper fadeInRight ibox-content">
    <header class="mui-bar mui-bar-nav">
        <div
                style="width: 120%; height: 6px; background: #29487D; margin-left: -20px"></div>
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"
           style="color: #29487D;"></a>
        <h1 class="mui-title">相关文件</h1>
    </header>
    <div
            style="width: 120%; height: 6px; background: #29487D; margin-top: 30px; margin-left: -20px"></div>
    <div class="title_top" th:object="${sysProjectFiles}"
         th:each="projectFile,iterStat : ${sysProjectFiles}">
        <span class="title" th:text="${projectFile.name}"></span>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-collapse"
                th:each="children,iterStat : ${projectFile.children}"><a
                    class="mui-navigate-right" href="#" th:text="${children.name}">
            </a> <i class="fa fa-check status1" aria-hidden="true"
                    th:style="${children.menuType ==0} ? 'display: none' : ''"> </i>
                <!--                <p class="status0"-->
                <!--                   th:style="${children.overdue ==1} ? 'display: none' : ''">已过期</p>-->
                <div class="mui-collapse-content">
                    <div class="mui-content-padded"
                         th:each="file,iterStat : ${children.children}">
                        <img th:src="${file.imgData}" data-preview-src=""
                             data-preview-group="1" style="width: 100%; height: 100%"/>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/js/mui.min.js}"></script>
<script th:src="@{/js/mui.zoom.js}"></script>
<script th:src="@{/js/mui.imageViewer.js}"></script>
<script th:src="@{/js/mui.previewimage.js}"></script>

<script type="text/javascript">
    mui.previewImage();
</script>

<script th:inline="javascript">
    var sysProjectFiles = [[${sysProjectFiles}]];
    $(function () {
        var imperfect = "";
        var temporaryCount = 0;
        for (var i = 0; i < sysProjectFiles.length; i++) {
            var projectFile = sysProjectFiles[i];
            if (!projectFile.children || projectFile.children < 1) {
                continue;
            }
            for (var j = 0; j < projectFile.children.length; j++) {
                var fileType = projectFile.children[j];
                if (fileType.menuType + "" && fileType.menuType == 0) {
                    if (fileType.name == "临时建设") {
                        continue;
                    }
                    if (imperfect.length == 0) {
                        imperfect += "<p style='text-align: left;font-size: 18px;color: #000;'>★:本工地以下资料未完善\n</p><div style='text-align: left;margin-left: 10%;font-size: 16px'>";
                    }
                    imperfect += fileType.name + "\n"
                }
            }
        }
        imperfect += "</div>"
        for (var i = 0; i < sysProjectFiles.length; i++) {
            var projectFile = sysProjectFiles[i];
            if (!projectFile.children || projectFile.children < 1) {
                continue;
            }

            for (var l = 0; l < projectFile.children.length; l++) {
                var fileType = projectFile.children[l];
                if (fileType.name != "临时建设") {
                    continue;
                }
                var temporaryTiltle = "★:本工地有" + fileType.children.length + "个临时建设:";
                if (imperfect && imperfect.indexOf(temporaryTiltle) == -1) {
                    imperfect += "<p style='text-align: left;font-size: 16px;color: #000;margin-top: 10px'>" + temporaryTiltle + "</p>";
                    imperfect += "<p style='text-align: left;font-size: 16px;color: #000;'>到期时间分别为</p><div style='text-align: left;margin-left: 10%;font-size: 16px'>";
                }
                if (!fileType.children || fileType.children < 1) {
                    continue;
                }
                var files = fileType.children;
                for (var f = 0; f < files.length; f++) {
                    var file = files[f];
                    var now = new Date();
                    var expirationDate = new Date(file.expirationTime);
                    console.log(expirationDate);
                    if (now.getTime() - expirationDate.getTime() < 0) {

                        var time = (expirationDate.getTime() - now.getTime()) / 1000 / 60 / 60 / 24;
                        if (parseInt(time) == 0) {
                            time = 1;
                        }
                        if (parseInt(time) < 30) {
                            imperfect += "<p >" + file.expirationTime
                            imperfect += "&nbsp;&nbsp;<span style='color: #BDBD00;'>(还有" + parseInt(time) + "天到期)" + "</span></p>"
                        } else {
                            imperfect += "<p >" + file.expirationTime
                            imperfect += "&nbsp;&nbsp;<span style='color: #008F00;'>(还有" + parseInt(time) + "天到期)" + "</span></p>"
                        }
                    } else {
                        imperfect += "<p >" + file.expirationTime
                        var time = (now.getTime() - expirationDate.getTime()) / 1000 / 60 / 60 / 24;
                        if (parseInt(time) == 0) {
                            time = 1;
                        }
                        imperfect += "&nbsp;&nbsp;<span style='color: #FF4545;'>(已到期" + parseInt(time) + "天)" + "</span></p>"
                    }

                }
            }
        }
        imperfect += "</div>"
        if (imperfect.length < 13) {
            return;
        }
        mui.alert(imperfect, function () {

        });
    })
</script>
</body>
</html>